package uscdb.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import uscdb.pageModel.Json;
import uscdb.service.SearchEnginesServiceI;

@Controller
@RequestMapping("/searchEnginesController")
public class SearchEnginesController {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(SearchEnginesController.class);

	@Autowired
	private SearchEnginesServiceI searchEnginesService;

	/**
	 * 使用restful接口触发更新索引
	 * 
	 * @return
	 */
	@RequestMapping("/updateIndex")
	@ResponseBody
	public Json updateIndex() {
		Json json = new Json();
		try {
			json.setMsg(searchEnginesService.updateIndex());
			json.setSuccess(true);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			json.setMsg("系统异常，请联系管理员");
		}
		return json;
	}

}
